home *** CD-ROM | disk | FTP | other *** search
/ CU Amiga Super CD-ROM 25 / CU Amiga Magazine's Super CD-ROM 25 (1998)(EMAP Images)(GB)(Track 1 of 2)[!][issue 1998-08].iso / CUCD / Programming / ixemul / sdk / man / cat3 / gethostbyname.0 < prev    next >
Encoding:
Text File  |  1998-06-15  |  7.4 KB  |  146 lines

  1.  
  2. GETHOSTBYNAME(3)           UNIX Programmer's Manual           GETHOSTBYNAME(3)
  3.  
  4. NNAAMMEE
  5.      ggeetthhoossttbbyynnaammee, ggeetthhoossttbbyyaaddddrr, ggeetthhoosstteenntt, sseetthhoosstteenntt, eennddhhoosstteenntt, hheerrrroorr,
  6.      hhssttrreerrrroorr - get network host entry
  7.  
  8. SSYYNNOOPPSSIISS
  9.      ##iinncclluuddee <<nneettddbb..hh>>
  10.      eexxtteerrnn iinntt hh__eerrrrnnoo;;
  11.  
  12.      _s_t_r_u_c_t _h_o_s_t_e_n_t _*
  13.      ggeetthhoossttbbyynnaammee(_c_o_n_s_t _c_h_a_r _*_n_a_m_e)
  14.  
  15.      _s_t_r_u_c_t _h_o_s_t_e_n_t _*
  16.      ggeetthhoossttbbyyaaddddrr(_c_o_n_s_t _c_h_a_r _*_a_d_d_r, _i_n_t _l_e_n, _i_n_t _t_y_p_e)
  17.  
  18.      _s_t_r_u_c_t _h_o_s_t_e_n_t _*
  19.      ggeetthhoosstteenntt(_v_o_i_d)
  20.  
  21.      _v_o_i_d
  22.      sseetthhoosstteenntt(_i_n_t _s_t_a_y_o_p_e_n)
  23.  
  24.      _v_o_i_d
  25.      eennddhhoosstteenntt(_v_o_i_d)
  26.  
  27.      _v_o_i_d
  28.      hheerrrroorr(_c_h_a_r _*_s_t_r_i_n_g)
  29.  
  30.      _c_h_a_r _*
  31.      hhssttrreerrrroorr(_i_n_t _e_r_r)
  32.  
  33. DDEESSCCRRIIPPTTIIOONN
  34.      The ggeetthhoossttbbyynnaammee() and ggeetthhoossttbbyyaaddddrr() functions each return a pointer
  35.      to an object with the following structure describing an internet host
  36.      referenced by name or by address, respectively.  This structure contains
  37.      either the information obtained from the name server, named(8),  broken-
  38.      out fields from a line in _/_e_t_c_/_h_o_s_t_s, or database entries supplied by the
  39.      yp(8) system .  If the local name server is not running these routines do
  40.      a lookup in _/_e_t_c_/_h_o_s_t_s.
  41.  
  42.      struct  hostent {
  43.              char    *h_name;        /* official name of host */
  44.              char    **h_aliases;    /* alias list */
  45.              int     h_addrtype;     /* host address type */
  46.              int     h_length;       /* length of address */
  47.              char    **h_addr_list;  /* list of addresses from name server */
  48.      };
  49.      #define h_addr  h_addr_list[0]  /* address, for backward compatibility */
  50.  
  51.      The members of this structure are:
  52.  
  53.      _h___n_a_m_e       Official name of the host.
  54.  
  55.      _h___a_l_i_a_s_e_s    A zero terminated array of alternate names for the host.
  56.  
  57.      _h___a_d_d_r_t_y_p_e   The type of address being returned; currently always
  58.                   AF_INET.
  59.  
  60.      _h___l_e_n_g_t_h     The length, in bytes, of the address.
  61.  
  62.      _h___a_d_d_r___l_i_s_t  A zero terminated array of network addresses for the host.
  63.                   Host addresses are returned in network byte order.
  64.  
  65.      _h___a_d_d_r       The first address in _h___a_d_d_r___l_i_s_t; this is for backward com-
  66.                   patibility.
  67.  
  68.                   When using the nameserver, ggeetthhoossttbbyynnaammee() will search for
  69.                   the named host in the current domain and its parents unless
  70.                   the name ends in a dot.  If the name contains no dot, and if
  71.                   the environment variable ``HOSTALIASES'' contains the name
  72.                   of an alias file, the alias file will first be searched for
  73.                   an alias matching the input name.  See hostname(7) for the
  74.                   domain search procedure and the alias file format.
  75.  
  76.                   The sseetthhoosstteenntt() function may be used to request the use of
  77.                   a connected TCP socket for queries.  If the _s_t_a_y_o_p_e_n flag is
  78.                   non-zero, this sets the option to send all queries to the
  79.                   name server using TCP and to retain the connection after
  80.                   each call to ggeetthhoossttbbyynnaammee() or ggeetthhoossttbbyyaaddddrr().  Otherwise,
  81.                   queries are performed using UDP datagrams.
  82.  
  83.                   The eennddhhoosstteenntt() function closes the TCP connection.
  84.  
  85. FFIILLEESS
  86.      /etc/hosts
  87.  
  88. DDIIAAGGNNOOSSTTIICCSS
  89.      Error return status from ggeetthhoossttbbyynnaammee() and ggeetthhoossttbbyyaaddddrr() is indicated
  90.      by return of a null pointer.  The external integer _h___e_r_r_n_o may then be
  91.      checked to see whether this is a temporary failure or an invalid or un-
  92.      known host.  The routine hheerrrroorr() can be used to print an error message
  93.      describing the failure.  If its argument _s_t_r_i_n_g is non-NULL, it is print-
  94.      ed, followed by a colon and a space.  The error message is printed with a
  95.      trailing newline.  The routine hhssttrreerrrroorr() returns a pointer to the mes-
  96.      sage string affiliated with an error number.  The array pointed to is not
  97.      to be modified by the program.
  98.  
  99.      The variable _h___e_r_r_n_o can have the following values:
  100.  
  101.      HOST_NOT_FOUND  No such host is known.
  102.  
  103.      TRY_AGAIN       This is usually a temporary error and means that the lo-
  104.                      cal server did not receive a response from an authorita-
  105.                      tive server.  A retry at some later time may succeed.
  106.  
  107.      NO_RECOVERY     Some unexpected server failure was encountered.  This is
  108.                      a non-recoverable error.
  109.  
  110.      NO_DATA         The requested name is valid but does not have an IP ad-
  111.                      dress; this is not a temporary error.  This means that
  112.                      the name is known to the name server but there is no ad-
  113.                      dress associated with this name.  Another type of request
  114.                      to the name server using this domain name will result in
  115.                      an answer; for example, a mail-forwarder may be regis-
  116.                      tered for this domain.
  117.  
  118. SSEEEE AALLSSOO
  119.      resolver(3),  hosts(5),  hostname(7),  named(8)
  120.  
  121. CCAAVVEEAATT
  122.      The ggeetthhoosstteenntt() function is defined, and sseetthhoosstteenntt() and eennddhhoosstteenntt()
  123.      are redefined, when libc(3) is built to use only the routines to lookup
  124.      in _/_e_t_c_/_h_o_s_t_s and not the name server.
  125.  
  126.      The ggeetthhoosstteenntt() function reads the next line of _/_e_t_c_/_h_o_s_t_s, opening the
  127.      file if necessary.
  128.  
  129.      The sseetthhoosstteenntt() function opens and/or rewinds the file _/_e_t_c_/_h_o_s_t_s. If
  130.      the _s_t_a_y_o_p_e_n argument is non-zero, the file will not be closed after each
  131.      call to ggeetthhoossttbbyynnaammee() or ggeetthhoossttbbyyaaddddrr().
  132.  
  133.      The eennddhhoosstteenntt() function closes the file.
  134.  
  135. HHIISSTTOORRYY
  136.      The hheerrrroorr() function appeared in 4.3BSD. The eennddhhoosstteenntt(),
  137.      ggeetthhoossttbbyyaaddddrr(), ggeetthhoossttbbyynnaammee(), ggeetthhoosstteenntt(), and sseetthhoosstteenntt() func-
  138.      tions appeared in 4.2BSD.
  139.  
  140. BBUUGGSS
  141.      These functions use static data storage; if the data is needed for future
  142.      use, it should be copied before any subsequent calls overwrite it.  Only
  143.      the Internet address format is currently understood.
  144.  
  145. 4.2 Berkeley Distribution       April 19, 1994                               3
  146.